
// const { json } = require("express/lib/response")
window.onload = function () {
    var username = document.querySelector('#username')
    var password = document.querySelector('#password')
    var zhuce = document.querySelector('#zhuce')
    zhuce.addEventListener('click', () => {
        // console.log(username.value, password.value);
        $.ajax({
            type: 'post',				// 请求方式
            url: 'http://127.0.0.1:3007/api/reguser',		// 路径
            // contentType: "application/json",
            dataType: 'json',		// 这里是指定了参数的类型
            data: {
                'username': username.value,
                'password': password.value
            },
            success: function (res) {
                // var yanzheng = { status: 0, message: '注册成功！' }
                // if (yanzheng == res) {
                if (res.status == 0) {
                    alert('注册成功');
                    self.location.href = "login.html";
                }
                else {
                    alert(res.message)
                }

                // }

                // window.open('login.html')
                // console.log(res);
            }
        })

    })
}